package ThreadDemo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 故我
 * Date: 2023-09-28
 * Time: 17:08
 */
public class ThreadDemo10 {
    public static void main(String[] args) {
        Thread t = new Thread(() -> {
            for (int i = 0; i < 100; i++) {
                //里面不进行sleep操作
                try {
                    Thread.sleep(10);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        System.out.println("t start 之前: " + t.getState());//此时线程对象创建，PCB未创建
        t.start();
        for (int j = 0; j < 100; j++) {
            System.out.println("t start 运行时: " + t.getState());
        }
        try {
            t.join();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        System.out.println("t start 之后: " + t.getState());//此时PCB已经释放，t对象设置为无效
    }
}
